#ifndef RPG_COMMON_TEMPLATE_ORZ
#define RPG_COMMON_TEMPLATE_ORZ

template<typename T>
class RPG_Common
{
public:
	T* m_data;
	bool auto_delete;

	RPG_Common(T* data = NULL)
	{
		if(data == NULL)
		{
			auto_delete = true;m_data = new T;
		}
		else
		{
			auto_delete = false;m_data = data;
		}
	}

	virtual ~RPG_Common()
	{
		if(auto_delete && m_data != NULL)
		{
			delete m_data;
			m_data = NULL;
		}
	}

	virtual T* SetData(T* data ,bool autoDelete = false,bool deleteOld = true)
	{
		T* old = m_data;
		m_data = data;

		auto_delete = autoDelete;
		
		if(deleteOld == false)
			return old;

		delete old;
		return NULL;
	}
};


template<typename T,typename V>
void RPG_CastSkill(T* caster,V* target,int skill_id)
{
	caster->castSkill(target,skill_id);
}
#endif